In [15]:
message= "hello Python world"
print(message)


hello Python world

In [16]:
message= "my shoes are old"
print(message)


my shoes are old

In [17]:
message= "my shoes are older than yours"

In [18]:
my_string='this is a single quote string'
print (my_string)


this is a single quote string

In [19]:
my_string= "this is a double quote string"
print (my_string)


this is a double quote string

In [20]:
quote= 'A coder once said, A string is as good as the author'
print quote


A coder once said, A string is as good as the author

In [21]:
first_name='John'
print (first_name)


John

In [22]:
print (first_name.title())


John

In [23]:
print (first_name.upper())


JOHN

In [24]:
print (first_name)
print (first_name.title())
print (first_name.upper())


John
John
JOHN

In [25]:
last_name = 'Thompson'
full_name = first_name+ ' ' +last_name
message=full_name.title()+ ' ' + "\tWas called the worst computer programmer at the place"

In [26]:
print (message)


John Thompson 	Was called the worst computer programmer at the place

In [27]:
print (message)


John Thompson 	Was called the worst computer programmer at the place

In [28]:
print (message)


John Thompson 	Was called the worst computer programmer at the place

In [29]:
print (message)


John Thompson 	Was called the worst computer programmer at the place

In [30]:
print "Hello everyone!"


Hello everyone!

In [31]:
print "\tHello everyone!"


	Hello everyone!

In [32]:
print "\nHello\n\n\n\neveryone!"


Hello



everyone!

In [32]:


In [33]:
print (3+2)


5

In [34]:
print 3*2


6

In [35]:
print (3**3)


27

In [36]:
print (3**3*3*3)


243

In [37]:
#made a few errors but succeeded in de-bugging most things my self

In [38]:
%%bash
pwd


/home/pi/learnpython

In [39]:
%%bash
cd /home
ls


adon
albert
aries
chanceis
cypress
daphne
destiny
eddie
frank
frankeyjoe
hohepa
hunnyb
izaeus
jaydean
john
kaiden
lance
laykon
lexxus
maurice
mercedes
meta
millie
nathan
nesian
ocean
pi
rayne
santana
shared
steven
tommy
traycin
tyrell
wai
william
zach
zcat

In [40]:
ls


Alex .ipynb       ian.ipynb      main.py.save.1  TK Hello World.ipynb
branches/         info/          main.py.save.2  Untitled0.ipynb
Bruce.ipynb       install6       objects/        Untitled1.ipynb
config            install6~      PeterW.ipynb    Untitled3.ipynb
d                 John T.ipynb   pybac.py        Untitled5.ipynb
Dele.ipynb        learnpy.ipynb  README.md       william.ipynb
description       learnpy.py     refs/           wp-post.py.save
HEAD              LICENSE        site
helloworld.ipynb  main.py        StephM.ipynb
hooks/            main.py.save   test/

Hello John. Some good process here. Rember you can assign number values to a variable - along with what you have done with strings already. Here's an example:


In [57]:
numb = 5
highnum = 15
print 5 + 15


20

There are many python modules that are not loaded by default. We can tell the program what to open by using the import command. random is a module worth getting to know.


In [58]:
import random

In [60]:
randnum = random.randint(0,20)

This will give you a random number between 0 and 20


In [63]:
print randnum


17

You should check out lists next - they are a great way of holding a bunch of data together. You can make something a list by using [ ]. Here's we go:


In [42]:
newlist = []
print newlist


[]

This makes a new empty list called newlist. There is nothing in it, but we can add to it with append


In [46]:
newlist.append(message)
print newlist


['John Thompson \tWas called the worst computer programmer at the place', 'John Thompson \tWas called the worst computer programmer at the place']

Lists are good because you can edit them. Another way of holding data is a tuple. These are made with ()


In [54]:
newtuple = ('hello', 'john', 'this is not a list')

In [55]:
print newtuple


('hello', 'john', 'this is not a list')

In [56]:
newtuple.count('hello')


Out[56]:
1

Tuples can not be changed unlike lists.


In [16]:
print(40/3)
print(7**2)
print(19-5)
print("This is a long line of text that has been \nedited with the new line command. \t\nThe tab command has been used as a further editing \nexercize")


13
49
14
This is a long line of text that has been 
edited with the new line command. 	
The tab command has been used as a further editing 
exercize

In [18]:
"""
Two edit commands can be used together
to create two seperate events on the same line
of text e.g....
"""
print("mary had a pair of shoes that did not fit her")


mary had a pair of shoes that did not fit her

mskannntoowehhh

Heading one


In [19]:
def addnum(mynumber):
    return mynumber + 5

In [21]:
addnum(-15)


Out[21]:
-10

In [28]:
addnum(+35)


Out[28]:
40

using markdown willgive auto notes.. Using heading gives pretty fonts format and compose by Simple function is def addnum(mynumber):then return mynumber (choose n+-) no multiply or division


In [31]:
print(type(3+7))
print(5*8)
print(type("Here is a written text"))


<type 'int'>
40
<type 'str'>

In [32]:
a = 3+5
b = a * a - a - 1
c = a * b
print(c)


440

In [36]:
a =3+5
b = a * a - a - 1
c = a * b
if (a>0):
    print(c)
else:
    print (c-a)


440

LISTS Remember the list begins at zero and you can change inividual values


In [37]:
a= [1, -7, 0, 0, 5, 10]
a [3]= "no number"
print a


[1, -7, 0, 'no number', 5, 10]

In [38]:
a [2]= 19
print a


[1, -7, 19, 'no number', 5, 10]

In [ ]: